'''重写迭代器 '''


class Myiter():

    def __init__(self,l=[]):
        self.mylist = l

    def __iter__(self):
        print(self.mylist)
        return Mynext(self.mylist)


class Mynext():
    def __init__(self,mylist):
        self.i = mylist
        self.index = 0

    def __next__(self):
        print('next被调用了')
        i = self.index
        self.index += 1
        if self.index >len(self.i):
            return '没了'
        return self.i[i]


mylist = Myiter([1,5,7,3,2,9,7,0])
myiter = iter(mylist)
print(next(myiter))
print(next(myiter))
print(next(myiter))